#include "gtest/gtest.h"

#include "LogImpl.h"
#include "Topic.h"
#include "ILog.h"

#include "MyLog.h"

/*  
ILog * ILog::create(Topic & topic){
	return new MyLog(topic);
}*/



/*  
IMeta * IMeta::create(ILog * log){
	return new MyMeta(log);
}*/

/*  
TEST(LogTest, testMain){
    Topic topic("stream-trans", ".");
    auto * log = new MyLog(topic);

    if(log->open()){
		size_t bytes = 0;
        log->append("hello", bytes);
        log->sync();
        log->truncate(0);
        log->close();
    }
	delete log;
}

TEST(MetaTest, testMain){
    Topic topic("stream-trans", ".");
    auto * recMeta = new MyMeta(topic);

    ASSERT_EQ(0ull, recMeta->size());

    recMeta->load();
    recMeta->isSync();
    recMeta->sync();
    //recMeta->sync(std::string_view &);

    recMeta->logSize().value();
    recMeta->logSize().advance(10);
    recMeta->logSize().overwrite(1024);

	delete recMeta;
}*/

/*  
TEST(LogImplTest, testMain){
    Topic topic("stream-trans", ".");
    LogImpl log(topic);

    ASSERT_TRUE(log.open()); //-> dir exist, file exist , file_header inited

    const char * msg = "hello cheng lun!";
    size_t appendBytes = 0;
    ASSERT_TRUE(log.append(msg, appendBytes));
    ASSERT_EQ(appendBytes, (strlen(msg) +  LogImpl::TransHeader::HeaderSize()));

    log.meta().addOffset(appendBytes);

    ASSERT_TRUE(log.close());
}
*/
